using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Sysgeprava.Entities;

namespace Sysgeprava.Repository.Mapping
{
    public class DET_ALIMENTACIONMap : EntityTypeConfiguration<DET_ALIMENTACION>
    {
        public DET_ALIMENTACIONMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Responsable)
                .IsRequired()
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("DET_ALIMENTACION");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.IdBovino).HasColumnName("IdBovino");
            this.Property(t => t.IdAlimento).HasColumnName("IdAlimento");
            this.Property(t => t.Cantidad).HasColumnName("Cantidad");
            this.Property(t => t.Fecha).HasColumnName("Fecha");
            this.Property(t => t.Responsable).HasColumnName("Responsable");

            // Relationships
            this.HasRequired(t => t.ALIMENTO)
                .WithMany(t => t.DET_ALIMENTACION)
                .HasForeignKey(d => d.IdAlimento);
            this.HasRequired(t => t.BOVINO)
                .WithMany(t => t.DET_ALIMENTACION)
                .HasForeignKey(d => d.IdBovino);

        }
    }
}
